{template 'common/header'}
{template 'common'}
<ul class="nav nav-tabs">
{if empty($shareid)}
	<li ><a href="{php echo create_url('site/entry', array('do' => 'charge', 'op' => 'list','m' => 'eso_sale','uniacid'=>$_W['uniacid']))}">会员信息</a></li>
	<li {if $operation == 'display' && $status == '1'}class="active"{/if}><a href="{php echo $this->createWebUrl('ordermy', array('op' => 'display', 'status' => 1,'uid'=>$_GPC['uid']))}">待发货</a></li>
	<!--<li {if $operation == 'display' && $sendtype == '2'}class="active"{/if}><a href="{php echo $this->createWebUrl('order', array('op' => 'display', 'status' => '-1', 'sendtype' => 2))}">待自提</a></li>-->
	<li {if $operation == 'display' && $status == '0'}class="active"{/if}><a href="{php echo $this->createWebUrl('ordermy', array('op' => 'display', 'status' => 0,'uid'=>$_GPC['uid']))}">待付款</a></li>
	<li {if $operation == 'display' && $status == '2'}class="active"{/if}><a href="{php echo $this->createWebUrl('ordermy', array('op' => 'display', 'status' => 2,'uid'=>$_GPC['uid']))}">待收货</a></li>
	<li {if $operation == 'display' && $status == '-1'}class="active"{/if}><a href="{php echo $this->createWebUrl('ordermy', array('op' => 'display', 'status' => -1,'uid'=>$_GPC['uid']))}">全部订单</a></li>
	{/if}
</ul>

{if $operation == 'display'}
<div class="main">
	<div style="padding:15px;">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:120px;">订单编号</th>
					<th style="width:100px;">会员姓名</th>
					<th style="width:80px;">联系电话</th>
					<th style="width:80px;">支付方式</th>
					{if empty($shareid)}
					<th style="width:80px;">配送方式</th>
					<th style="width:50px;">运费</th>			
                    {/if}
					<th style="width:50px;">总价</th>             
<!--				<th style="width:50px;">类型</th>-->
					<th style="width:50px;">状态</th>
					<th style="width:150px;">下单时间</th>
					{if !empty($shareid)}
					<th style="width:50px;">1级佣金</th>			
					<th style="width:50px;">2级佣金</th>		
						<th style="width:50px;">3级佣金</th>		
                    {/if}
					{if empty($shareid)}
					<th style="width:120px;">操作</th>
					{/if}
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td>{$item['ordersn']}</td>
					<td>{$address[$item['addressid']]['realname']}</td>
					<td>{$address[$item['addressid']]['mobile']}</td>
					<td>{if $item['paytype'] == 2}<span class="label label-important">在线支付</span>{/if}{if $item['paytype'] == 3}<span class="label label-warning">货到付款</span>{/if}</td>
					{if empty($shareid)}
					<td>{if empty($item['dispatch'])}自提{else}{$item['dispatch']['dispatchname']}{/if}</td>
                                        <td>{$item['dispatchprice']}</td>
					{/if}
					<td>{$item['price']} 元</td>
<!--					<td>{if $item['goodstype']}实物{else}虚拟{/if}</td>-->
					<td>
						{if $item['status'] == 0}<span class="label label-info">待付款</span>{/if}
						{if $item['status'] == 1}<span class="label label-info">待发货</span>{/if}
						{if $item['status'] == 2}<span class="label label-info">待收货</span>{/if}
						{if $item['status'] == 3}<span class="label label-success">已完成</span>{/if}
						{if $item['status'] == -1}<span class="label label-success">已关闭</span>{/if}</td>
					<td>{php echo date('Y-m-d H:i:s', $item['createtime'])}</td>
					{if !empty($shareid)}
					<td>{if $item['status'] == 3}{$item['commission']}元{else}--{/if}</td>
							<td>{if $item['status'] == 3}{$item['commission2']}元{else}--{/if}</td>
									<td>{if $item['status'] == 3}{$item['commission3']}元{else}--{/if}</td>
                    {/if}
					{if empty($shareid)}
					<td><a href="{php echo $this->createWebUrl('ordermy', array('op' => 'detail', 'id' => $item['id'],'from_user'=>$_GPC['from_user']))}">查看详情</a></td>
					{/if}
				</tr>
				{/loop}
			</tbody>
			<!--tr>
				<td></td>
				<td colspan="3">
					<input name="token" type="hidden" value="{$_W['token']}" />
					<input type="submit" class="btn btn-primary" name="submit" value="提交" />
				</td>
			</tr-->
		</table>
		{$pager}
	</div>
</div>
{elseif $operation == 'detail'}
<div class="main">
	<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data" onsubmit="return formcheck(this)">
		{if $item['transid']}<div style="margin:10px 0; width:auto;" class="alert alert-error"><i class="icon-lightbulb"></i> 此为微信支付订单，必须要提交发货状态！</div>{/if}
		<input type="hidden" name="id" value="{$item[id]}">
		<h4>订单信息</h4>
		<table class="tb">

			<tr>
				<th ><label for="">收货人姓名:</label></th>
				<td >
					{$item['user']['realname']}
				</td>
				<th ><label for="">联系电话:</label></th>
				<td >
					{$item['user']['mobile']}
				</td>
			</tr>
			
			<tr>
				<th><label for="">订单编号:</label></th>
				<td>
					{$item['ordersn']}
				</td>
				<th><label for="">总金额:</label></th>
				<td>
					{$item['price']} 元 （商品: {$item['goodsprice']} 元 运费: {$item['dispatchprice']} 元)
				</td>
			</tr>
			<tr>
			<th><label for="">下单时间：</label></th>
				<td>
					{php echo date('Y-m-d H:i:s', $item['createtime'])}
				</td>
				<th><label for="">收货地址：</label></th>
				<td>
					{$item['user']['province']}{$item['user']['city']}{$item['user']['area']}{$item['user']['address']}
				</td>
			</tr>
			
			
			
			<tr>
				<th><label for="">分销员：</label></th>
				<td>{if !empty($member[$item['shareid']])}
					{$member[$item['shareid']]}
					{else} -- {/if}
				</td>
						<th><label for="">订单状态：</label></th>
				<td>
					{if $item['status'] == 0}<span class="label label-info">待付款</span>{/if}
					{if $item['status'] == 1}<span class="label label-info">待发货</span>{/if}
					{if $item['status'] == 2}<span class="label label-info">待收货</span>{/if}
					{if $item['status'] == 3}<span class="label label-success">已完成</span>{/if}
					{if $item['status'] == -1}<span class="label label-success">已关闭</span>{/if}
				</td>
			</tr>
			</tr>
			
		<!--	<tr>
				<th><label for="">价钱</label></th>
				<td>
					{$item['price']} 元 （商品: {$item['goodsprice']} 元 运费: {$item['dispatchprice']} 元)
				</td>
			</tr>-->
			<tr>
				<th><label for="">配送方式：</label></th>
				<td>
					{if empty($dispatch)}自提{else}{$dispatch['dispatchname']}{/if}
				</td>
					<th><label for="">付款方式：</label></th>
				<td>
					{if $item['paytype'] == 1}余额支付{/if}
					{if $item['paytype'] == 2}在线支付{/if}
					{if $item['paytype'] == 3}货到付款{/if}
				</td>
			</tr>
			<!--<tr>
				<th><label for="">付款方式</label></th>
				<td>
					{if $item['paytype'] == 1}余额支付{/if}
					{if $item['paytype'] == 2}在线支付{/if}
					{if $item['paytype'] == 3}货到付款{/if}
				</td>
			</tr>
			<tr>
				<th><label for="">订单状态</label></th>
				<td>
					{if $item['status'] == 0}<span class="label label-info">待付款</span>{/if}
					{if $item['status'] == 1}<span class="label label-info">待发货</span>{/if}
					{if $item['status'] == 2}<span class="label label-info">待收货</span>{/if}
					{if $item['status'] == 3}<span class="label label-success">已完成</span>{/if}
					{if $item['status'] == -1}<span class="label label-success">已关闭</span>{/if}
				</td>
			</tr>
			<tr>
				<th><label for="">下单日期</label></th>
				<td>
					{php echo date('Y-m-d H:i:s', $item['createtime'])}
				</td>
			</tr>-->
			<!--<tr>
				<th>备注</th>
				<td>
					<textarea style="height:150px;" class="span7" name="remark" cols="70">{$item['remark']}</textarea>
				</td>
			</tr>-->
		</table>
		<!--<h4>用户信息</h4>
		<table class="tb">
			<tr>
				<th><label for="">姓名</label></th>
				<td>
					{$item['user']['realname']}
				</td>
			</tr>
			<tr>
				<th><label for="">手机</label></th>
				<td>
					{$item['user']['mobile']}
				</td>
			</tr>
			<tr>
				<th><label for="">QQ</label></th>
				<td>
					{$item['user']['qq']}
				</td>
			</tr>
			<tr>
				<th><label for="">地址</label></th>
				<td>
					{$item['user']['province']}{$item['user']['city']}{$item['user']['area']}{$item['user']['address']}
				</td>
			</tr>
		</table>
		<h4>商品列表</h4>-->
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:30px;">ID</th>
					<th style="min-width:350px;">商品标题</th>
                                        <th style="min-width:250px;">商品规格</th>
					<th style="width:100px;">商品编号</th>
					<th style="width:100px;">商品条码</th>
                                        
					<!--<th style="width:100px;">销售价/成本价</th>
					<th style="width:100px;">属性</th>-->
                                        <th style="width:80px;color:red;">成交价</th>
					<th style="width:50px;">数量</th>
					<!--<th style="text-align:right; min-width:60px;">操作</th>-->
				</tr>
			</thead>
			{loop $item['goods'] $goods}
			<tr>
				<td>{$goods['id']}</td>
				<td>{if $category[$goods['pcate']]['name']}
                                    <span class="text-error">[{$category[$goods['pcate']]['name']}] </span>{/if}{if $children[$goods['pcate']][$goods['ccate']][1]}
                                    <span class="text-info">[{$children[$goods['pcate']][$goods['ccate']][1]}] </span>{/if}
                                    {$goods['title']}
                                
                                </td>
                                <td> {if !empty($goods['optionname'])}{$goods['optionname']}{/if}</td>
				<td>{$goods['goodssn']}</td>
				<td>{$goods['productsn']}</td>
                               
				<!--td>{$category[$goods['pcate']]['name']} - {$children[$goods['pcate']][$goods['ccate']][1]}</td-->
				<!--<td style="background:#f2dede;">{$goods['marketprice']}元 / {$goods['productprice']}元</td>
				<td>{if $goods['status']==1}<span class="label label-success">上架</span>{else}<span class="label label-error">下架</span>{/if}&nbsp;<span class="label label-info">{if $goods['type'] == 1}实体商品{else}虚拟商品{/if}</span></td>-->
                                 <td style='color:red;font-weight:bold;'>{$goods['orderprice']}</td>
				<td>{$goods['total']}</td>
				<!--<td style="text-align:right;">
					<a href="{php echo $this->createWebUrl('goods', array('id' => $goods['id'], 'op' => 'post'))}">编辑</a>&nbsp;&nbsp;<a href="{php echo $this->createWebUrl('goods', array('id' => $goods['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;">删除</a>
				</td>-->
			</tr>
			{/loop}
		</table>
		<table class="tb">
		
			<tr>
				<th>备注</th>
				<td>
					<textarea style="height:150px;" class="span7" name="remark" cols="70">{$item['remark']}</textarea>
				</td>
			</tr>
		</table>
		<table class="tb">
			<tr>
				<th></th>
				<td>
					{if empty($item['status'])}
						<button type="submit" class="btn btn-primary span2" onclick="return confirm('确认付款此订单吗？'); return false;" name="confrimpay" onclick="" value="yes">确认付款</button>
					{elseif $item['status'] == 1}
						 {if !empty($dispatch)}
						<button type="button" class="btn btn-primary span2" name="confirmsend" onclick="$('#modal-confirmsend').modal()" value="yes">确认发货</button>
						<!--<button type="button" class="btn btn-danger span2" name="cancelsend" onclick="$('#modal-cancelsend').modal();" value="yes">取消发货</button>-->
                                                {/if}
						 
					{elseif $item['status'] == 2}
						  {if !empty($dispatch)}
						<button type="button" class="btn btn-danger span2" name="cancelsend" onclick="$('#modal-cancelsend').modal();" value="yes">取消发货</button>
                                                                                                             {/if}
						 
					{elseif $item['status'] == 3}

					{/if}
					{if $item['status'] != 3}
					<button type="submit" class="btn btn-success span2" onclick="return confirm('确认完成此订单吗？'); return false;" name="finish" onclick="" value="yes">完成订单</button>
					<button type="button" class="btn span2" name="close" onclick="$('#modal-close').modal()" value="关闭">关闭订单</button>
					{/if}
					<input type="hidden" name="token" value="{$_W['token']}" />
				</td>
			</tr>
		</table>
		<div id="modal-confirmsend" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true" style=" width:600px;">
			<div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>快递信息</h3></div>
			<div class="modal-body">
				<table class="tb">
					<tr>
						<th><label for="">是否需要快递</label></th>
						<td>
							<label for="radio_1" class="radio inline"><input type="radio" name="isexpress" id="radio_1" value="1" onclick="$('#expresspanel').show();" checked autocomplete="off"> 是</label>
							<label for="radio_2" class="radio inline"><input type="radio" name="isexpress" id="radio_2" value="0" onclick="$('#expresspanel').hide();" autocomplete="off"> 否</label>
						</td>
					</tr>
					<tbody id="expresspanel">
						<tr>
							<th><label for="">快递公司</label></th>
							<td>
								<select name="express" id='express'>
                                                                    
                                                                      

									<option value="" data-name="">其他快递</option>
<option value="shunfeng" data-name="顺丰">顺丰</option>
<option value="shentong" data-name="申通">申通</option>
<option value="yunda" data-name="韵达快运">韵达快运</option>
<option value="tiantian" data-name="天天快递">天天快递</option>
<option value="yuantong" data-name="圆通速递">圆通速递</option>
<option value="zhongtong" data-name="中通速递">中通速递</option>
<option value="ems" data-name="ems快递">ems快递</option>
<option value="huitongkuaidi" data-name="汇通快运">汇通快运</option>
<option value="quanfengkuaidi" data-name="全峰快递">全峰快递</option>
<option value="zhaijisong" data-name="宅急送">宅急送</option>
<option value="aae" data-name="aae全球专递">aae全球专递</option>
<option value="anjie" data-name="安捷快递">安捷快递</option>
<option value="anxindakuaixi" data-name="安信达快递">安信达快递</option>
<option value="biaojikuaidi" data-name="彪记快递">彪记快递</option>
<option value="bht" data-name="bht">bht</option>
<option value="baifudongfang" data-name="百福东方国际物流">百福东方国际物流</option>
<option value="coe" data-name="中国东方（COE）">中国东方（COE）</option>
<option value="changyuwuliu" data-name="长宇物流">长宇物流</option>
<option value="datianwuliu" data-name="大田物流">大田物流</option>
<option value="debangwuliu" data-name="德邦物流">德邦物流</option>
<option value="dhl" data-name="dhl">dhl</option>
<option value="dpex" data-name="dpex">dpex</option>
<option value="dsukuaidi" data-name="d速快递">d速快递</option>
<option value="disifang" data-name="递四方">递四方</option>
<option value="fedex" data-name="fedex（国外）">fedex（国外）</option>
<option value="feikangda" data-name="飞康达物流">飞康达物流</option>
<option value="fenghuangkuaidi" data-name="凤凰快递">凤凰快递</option>
<option value="feikuaida" data-name="飞快达">飞快达</option>
<option value="guotongkuaidi" data-name="国通快递">国通快递</option>
<option value="ganzhongnengda" data-name="港中能达物流">港中能达物流</option>
<option value="guangdongyouzhengwuliu" data-name="广东邮政物流">广东邮政物流</option>
<option value="gongsuda" data-name="共速达">共速达</option>
<option value="hengluwuliu" data-name="恒路物流">恒路物流</option>
<option value="huaxialongwuliu" data-name="华夏龙物流">华夏龙物流</option>
<option value="haihongwangsong" data-name="海红">海红</option>
<option value="haiwaihuanqiu" data-name="海外环球">海外环球</option>
<option value="jiayiwuliu" data-name="佳怡物流">佳怡物流</option>
<option value="jinguangsudikuaijian" data-name="京广速递">京广速递</option>
<option value="jixianda" data-name="急先达">急先达</option>
<option value="jjwl" data-name="佳吉物流">佳吉物流</option>
<option value="jymwl" data-name="加运美物流">加运美物流</option>
<option value="jindawuliu" data-name="金大物流">金大物流</option>
<option value="jialidatong" data-name="嘉里大通">嘉里大通</option>
<option value="jykd" data-name="晋越快递">晋越快递</option>
<option value="kuaijiesudi" data-name="快捷速递">快捷速递</option>
<option value="lianb" data-name="联邦快递（国内）">联邦快递（国内）</option>
<option value="lianhaowuliu" data-name="联昊通物流">联昊通物流</option>
<option value="longbanwuliu" data-name="龙邦物流">龙邦物流</option>
<option value="lijisong" data-name="立即送">立即送</option>
<option value="lejiedi" data-name="乐捷递">乐捷递</option>
<option value="minghangkuaidi" data-name="民航快递">民航快递</option>
<option value="meiguokuaidi" data-name="美国快递">美国快递</option>
<option value="menduimen" data-name="门对门">门对门</option>
<option value="ocs" data-name="OCS">OCS</option>
<option value="peisihuoyunkuaidi" data-name="配思货运">配思货运</option>
<option value="quanchenkuaidi" data-name="全晨快递">全晨快递</option>
<option value="quanjitong" data-name="全际通物流">全际通物流</option>
<option value="quanritongkuaidi" data-name="全日通快递">全日通快递</option>
<option value="quanyikuaidi" data-name="全一快递">全一快递</option>
<option value="rufengda" data-name="如风达">如风达</option>
<option value="santaisudi" data-name="三态速递">三态速递</option>
<option value="shenghuiwuliu" data-name="盛辉物流">盛辉物流</option>
<option value="sue" data-name="速尔物流">速尔物流</option>
<option value="shengfeng" data-name="盛丰物流">盛丰物流</option>
<option value="saiaodi" data-name="赛澳递">赛澳递</option>
<option value="tiandihuayu" data-name="天地华宇">天地华宇</option>
<option value="tnt" data-name="tnt">tnt</option>
<option value="ups" data-name="ups">ups</option>
<option value="wanjiawuliu" data-name="万家物流">万家物流</option>
<option value="wenjiesudi" data-name="文捷航空速递">文捷航空速递</option>
<option value="wuyuan" data-name="伍圆">伍圆</option>
<option value="wxwl" data-name="万象物流">万象物流</option>
<option value="xinbangwuliu" data-name="新邦物流">新邦物流</option>
<option value="xinfengwuliu" data-name="信丰物流">信丰物流</option>
<option value="yafengsudi" data-name="亚风速递">亚风速递</option>
<option value="yibangwuliu" data-name="一邦速递">一邦速递</option>
<option value="youshuwuliu" data-name="优速物流">优速物流</option>
<option value="youzhengguonei" data-name="邮政包裹挂号信">邮政包裹挂号信</option>
<option value="youzhengguoji" data-name="邮政国际包裹挂号信">邮政国际包裹挂号信</option>
<option value="yuanchengwuliu" data-name="远成物流">远成物流</option>
<option value="yuanweifeng" data-name="源伟丰快递">源伟丰快递</option>
<option value="yuanzhijiecheng" data-name="元智捷诚快递">元智捷诚快递</option>
<option value="yuntongkuaidi" data-name="运通快递">运通快递</option>
<option value="yuefengwuliu" data-name="越丰物流">越丰物流</option>
<option value="yad" data-name="源安达">源安达</option>
<option value="yinjiesudi" data-name="银捷速递">银捷速递</option>
<option value="zhongtiekuaiyun" data-name="中铁快运">中铁快运</option>
<option value="zhongyouwuliu" data-name="中邮物流">中邮物流</option>
<option value="zhongxinda" data-name="忠信达">忠信达</option>
<option value="zhimakaimen" data-name="芝麻开门">芝麻开门</option>
								</select>
                                                            <input type='hidden' class='input span3' name='expresscom' id='expresscom'  />
							</td>
						</tr>
						<tr>
							<th><label for="">快递单号</label></th>
							<td>
								<input type="text" name="expresssn" class="span5" />
							</td>
						</tr>
					</tbody>
				</table>
				<div id="module-menus"></div>
			</div>
			<div class="modal-footer"><button type="submit" class="btn btn-primary span2" name="confirmsend" value="yes">确认发货</button><a href="#" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a></div>
		</div>
		<div id="modal-cancelsend" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true" style=" width:600px;">
			<div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>取消发货</h3></div>
			<div class="modal-body">
				<table class="tb">
					<tr>
						<th><label for="">取消发货原因</label></th>
						<td>
							<textarea style="height:150px;" class="span5" name="cancelreson" cols="70" autocomplete="off"></textarea>
						</td>
					</tr>
				</table>
				<div id="module-menus"></div>
			</div>
			<div class="modal-footer"><button type="submit" class="btn btn-primary span2" name="cancelsend" value="yes">取消发货</button><a href="#" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a></div>
		</div>
		<div id="modal-close" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true" style=" width:600px;">
			<div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>关闭订单</h3></div>
			<div class="modal-body">
				<table class="tb">
					<tr>
						<th><label for="">关闭订单原因</label></th>
						<td>
							<textarea style="height:150px;" class="span5" name="reson" cols="70" autocomplete="off"></textarea>
						</td>
					</tr>
				</table>
				<div id="module-menus"></div>
			</div>
			<div class="modal-footer"><button type="submit" class="btn btn-primary span2" name="close" value="yes">关闭订单</button><a href="#" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a></div>
		</div>
	</form>
</div>
<script language='javascript'>
     $(function(){
         {if !empty($express)}
             $("#express").val("{$express['express_url']}");
             $("#expresscom").val(  $("#express").find("option:selected").attr("data-name"));
         {/if}
             
        $("#express").change(function(){
          
            var obj = $(this);  
            var sel =obj.find("option:selected").attr("data-name");
            $("#expresscom").val(  sel.val() );
        });
      
    })
    
</script>
{/if}
{template 'common/footer'}
